package org.lejos.example;

// LightSensorPoll.java

import gin.and.tonic.*;
import lejos.nxt.Button;
import lejos.nxt.ButtonListener;

public class LightSensorPoll implements ButtonListener
{
  private volatile boolean isRunning = true;

  public LightSensorPoll()
  {
    NxtRobot robot = new NxtRobot();
    Button.ESCAPE.addButtonListener(this);
    LightSensor ls = new LightSensor(SensorPort.S3);
    robot.addPart(ls);
    ls.activate(true);
    while (isRunning)
    {
      System.out.println("v: " + ls.getValue());
      Tools.delay(500);
    }
    robot.exit();
  }

  public void buttonPressed(Button b)
  {
    isRunning = false;
  }

  public void buttonReleased(Button b)
  {
  }

  public static void main(String[] args)
  {
    new LightSensorPoll();
  }
}